/**
 * Created by Administrator on 2016/8/4.
 */

var position_name,position_code,department_Id, currentID, flag = true;
function Personload() {
    $('#table').bootstrapTable({
        type: "GET",
        striped: true,
        singleSelect: false,
        url:"",
        dataType: "json",
        pagination: true, //分页
        pageSize: 10,
        pageNumber: 1,
        search: false, //显示搜索框
        contentType: "application/x-www-form-urlencoded",
        queryParams: null,
        columns: [
        	{
				title : "选择",
                checkbox:"true",
                align: 'center',
                valign: 'middle'
            },
            {
                visible:false,//隐藏列
                field: 'id',
                align: 'center',
                valign: 'middle'
            },
            {
                title: "职位编码",
                field: 'position_code',
                align: 'center',
                valign: 'middle'
            },
            {
                title: '职位名称',
                field: 'position_name',
                align: 'center',
                valign: 'middle'
            },
            {
                title: '职位分类',
                field: 'posClassName',
                align: 'center'
            },
            {
                title: '所属部门',
                field: 'department',
                align: 'center'
            },
                     
            
        ]
    });
    getData();
}
function getData() {
	
	position_name = $("#position_name").val();
    position_code = $("#position_code").val();
    department_Id = $("#department_Id").val();
   
    
    $.ajax({
        type: "GET",
        url: "select_position.json",
        data:{
        	"position_name":position_name,
        	"position_code":position_code,
        	"department_Id":department_Id
        },
        dataType: "json",
        success: function (result) {
            if (result.data) {
                var TableData = result.data;
                $('#table').bootstrapTable("load", TableData);
            }
        }
    })
}

		var path=$("#path").val();
	//确定
	function yes(){
		var row = $.map($('#table').bootstrapTable('getSelections'),function (row) {
			var position_id=row["id"];
			var p_name=row["position_name"];
			var p_code=row["position_code"];
			var p_oz_name=row["department"];
			alert(position_id)
			alert(p_name)
			alert(path)
			document.getElementById("position_id").value = position_id;
			document.getElementById("position_name").value = p_name;
			document.getElementById("position_code").value = p_code;
			document.getElementById("oz_name").value = p_oz_name;
			
		
		
		});
		/*window.location.href =path+"/rtpo.html";*/
		 $.ajax({
		        type: "GET",
		        url: path+"/rtpo.json",
		       /* data:{
		        	"position_name":position_name,
		        	"position_code":position_code,
		        	"department_Id":department_Id
		        },*/
		        dataType: "json",
		        success: function (result) {
		        	window.location.href =path+"/rtpo.html";
		         /*   if (result.data) {
		                var TableData = result.data;
		                $('#table').bootstrapTable("load", TableData);
		            }*/
		        }
		    })
	}
	
	function yess(){
		var position_id=null;
		/*window.location.href =path+"/rtpo.html";*/
		var row = $.map($('#table').bootstrapTable('getSelections'),function (row) {
			 position_id=row["id"];
			var p_name=row["position_name"];
			var p_code=row["position_code"];
			var p_oz_name=row["department"];
			alert(position_id)
			alert(p_name)
			alert(path)
			/*document.getElementById("position_id").value = position_id;
			document.getElementById("position_name").value = p_name;
			document.getElementById("position_code").value = p_code;
			document.getElementById("oz_name").value = p_oz_name;*/
			window.location.href =path+"/rtpo.html";
		
		});
	/*	layer.open({
			  content: dat,
			  btn: ['确定'],
			  yes: function(index, layero){
			    //事件
			    layer.close(indxex);
			  }
			});*/

		 /*location.reload()*/
		 /*$.ajax({
		        type: "GET",
		        url: path+"/rtpo.json",
		        data:{
		        	"position_name":position_name,
		        	"position_code":position_code,
		        	"department_Id":department_Id
		        },
		        dataType: "json",
		        success: function (result) {
		        	alert(position_id)
		            
		        }
		    })*/
	}
	



function addPos(){
	
	
    alert("ajax!");
    $.ajax({
        type: "GET",
        url: "select_position.json",
        data:{
        	"position_name":position_name,
        	"position_code":position_code,
        	"department_Id":department_Id
        },
        dataType: "json",
        success: function (result) {
            if (result.data) {
                var TableData = result.data;
                $('#table').bootstrapTable("load", TableData);
            }
        }
    })
}
function open() {
	alert("进入open");
}






